<script setup>
import { ref, onMounted, getCurrentInstance } from "vue";
import { useUserStore } from "../store/user";
import { useRouter } from "vue-router";
// import nav from "../components/nav.vue";

const router = useRouter();
const { ctx } = getCurrentInstance();
// console.log("ctx", ctx);

const userStore = useUserStore();
console.log("userStore", userStore);
const routers = ref([]);
const msg = userStore.getMsg;
console.log("msg", msg.value);
onMounted(() => {
  // console.log(router.currentRoute)
  //router.push({path:'/statistics',query:{userid:'106b435d-8288-4dc8-9ca2-8dc3150c0bec'},})
  //router.push({path:'/analysis',query:{userid:'106b435d-8288-4dc8-9ca2-8dc3150c0bec'},})
  //router.push({path:'/contract',query:{userid:'106b435d-8288-4dc8-9ca2-8dc3150c0bec'},})
  userStore.changeMsg("这个是新消息");
  console.log(userStore.getMsg);
  const allRoutes = router.getRoutes();
  console.log("所有路由:", allRoutes);
  routers.value = allRoutes;
});
</script>
<template>
  <div>
    <van-nav-bar title="标题1" />
    <nav class="flex gap-5 flex-wrap">
      <router-link
        v-for="(item, index) in routers"
        :to="item.path"
        :key="index"
        class="px-3 py-1.5 text-xl border-1 border-solid border-gray-400 rounded-md"
        >{{ item.name }}</router-link
      >
    </nav>
    <div>{{ msg }}</div>
    <button @click="userStore.changeMsg('者又是一个新消息')">改变消息</button>
    <div>
      <h2>{{ $translate("greetings.hi") }}</h2>
      <span>il8n代码示例</span>
    </div>
    <div class="dflex" style="flex-wrap: wrap">
      <div class="padding-sm">
        <van-button
          round
          type="primary"
          class="margin-sm"
          to="statistics?userid=106b435d-8288-4dc8-9ca2-8dc3150c0bec"
          >statistics</van-button
        >
      </div>
      <div class="padding-sm">
        <van-button
          round
          type="primary"
          to="analysis?userid=106b435d-8288-4dc8-9ca2-8dc3150c0bec"
          >analysis</van-button
        >
      </div>
      <div class="padding-sm">
        <van-button
          round
          type="primary"
          to="contract?userid=106b435d-8288-4dc8-9ca2-8dc3150c0bec"
          >contract</van-button
        >
      </div>
      <div class="padding-sm">
        <van-button round type="primary" to="demo">demo</van-button>
      </div>
      <div class="padding-sm">
        <van-button round type="primary" to="qiwei">企业微信调试接口</van-button>
      </div>
      <div class="padding-sm">
        <van-button round type="primary" to="monitor">聚友工具箱</van-button>
      </div>
      <div class="padding-sm">
        <van-button round type="primary" to="es6">es6</van-button>
      </div>
      <div class="padding-sm">
        <van-button round type="primary" to="canvas">canvas</van-button>
      </div>
    </div>
  </div>
</template>
<style lang="scss"></style>
